<template>
  <el-tag :type="type">{{ label }}</el-tag>
</template>

<script setup>
import { column } from 'element-plus/es/components/table-v2/src/common.mjs'
import { onMounted } from 'vue'

const value = defineModel()
const props = defineProps({
  row: {
    type: Object,
    default: () => ({}),
  },
  column: {
    type: column,
    default: () => ({}),
  },
  statusMap: {
    type: Array,
    default: () => [],
  },
})
const type = ref('primary')
const label = ref('')
onMounted(() => {
  // 如果有statusShow属性，则通过map控制标签风格
  if (props.column.statusShow && props.row.statusShow) {
    label.value = props.row.statusShow
    type.value = props.column.statusTypeMap[props.row.status] || 'success'
  } else {
    if (props.row.status === 'Enabled') {
      type.value = 'success'
      label.value = '启用'
    } else {
      type.value = 'danger'
      label.value = '停用'
    }
  }
})
</script>

<style lang="scss" scoped></style>
